//
//  HRZGoodsClassifyContentModel.m
//  EMarket
//
//  Created by 石头 on 2018/7/31.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZGoodsClassifyContentModel.h"
// Controllers

// Models

// Views

// Vendors

// Categories

// Others


@implementation HRZClassifyTypeModel

+ (id)initBaseModel{
    HRZClassifyTypeModel *model = [[HRZClassifyTypeModel alloc] init];
    model.name = [NSString stringWithFormat:@"Type_%d", arc4random()%8];
    
    NSMutableArray *subArr = [NSMutableArray array];
    for (int i = 0; i < arc4random()%8 + 1; i++) {
        HRZBaseModel *model = [HRZGoodsClassifyBaseModel initBaseModel];
        [subArr addObject:model];
    }
    
    model.subArray = subArr;
    
    return model;
}

@end

@implementation HRZGoodsClassifyContentModel

+ (NSDictionary *)mj_objectClassInArray
{
    return @{
             @"secondClassify":@"HRZGoodsClassifySecondModel",
             @"brand":@"HRZGoodsClassifyBrandModel"
             };
}

- (NSArray<HRZClassifyTypeModel *> *)classifyArray {
    
    if (!_classifyArray) {
        NSMutableArray *array = [NSMutableArray array];
        /** 添加主类型 */
        if (self.classify) {
            HRZClassifyTypeModel *model = [[HRZClassifyTypeModel alloc] init];
            model.type = ClassifyTypeSearch;
            model.modelId = self.classify.modelId;
            model.name = self.classify.className;
            model.imageUrl = self.classify.classifyImg;
            model.subArray = [NSArray arrayWithObject:self.classify];
            [array addObject:model];
        }
        
        /** 添加自分类 */
        for (int i = 0; i < self.secondClassify.count; i++) {
            HRZClassifyTypeModel *model = [[HRZClassifyTypeModel alloc] init];
            model.type = ClassifyTypeClassify;
            HRZGoodsClassifySecondModel *secondModel = [self.secondClassify objectAtIndex:i];
            model.name = secondModel.classify.className;
            model.modelId = secondModel.classify.modelId;
            model.imageUrl = secondModel.classify.classifyImg;
            model.subArray = [NSArray arrayWithArray:secondModel.threeClassify];
            [array addObject:model];
        }
        
        /** 添加品牌 */
        if (self.brand.count) {
            HRZClassifyTypeModel *model = [[HRZClassifyTypeModel alloc] init];
            model.type = ClassifyTypeBrand;
            model.modelId = @"";
            model.name = @"品牌";
            model.imageUrl = @"";
            model.subArray = [NSArray arrayWithArray:self.brand];
            [array addObject:model];
        }
        
        _classifyArray = [NSArray arrayWithArray:array];
    }
    
    
    return _classifyArray;
}

@end
